extends IBasicComponent


class_name StateComponent
"""
适配对象的完成状态逻辑
"""


## 适配的对象
@export var wrapper: Node = null


## 当前状态
var __state: int = 0
## 状态持续时间
var __state_duration: float = 0


## 状态切换
func __transition_to(next: int) -> void:
    __state = next
    __state_duration = 0

func _physics_process(delta: float) -> void:
    __state_duration += delta
    # 迭代状态
    var next: int = wrapper.yield_state(__state, delta, __state_duration)
    if __state != next:
        __transition_to(next)
